import java.util.*;
import java.util.regex.*;

public class StringParser {
    public Set<String> parse(String s) {
        if (s == null)
            throw new NullPointerException();

        Set<String> words = new HashSet<String>();
        Pattern p = Pattern.compile("\\b[A-Za-z[-]а-яА-ЯёЁ]+\\b");
        Matcher m = p.matcher(s);
        while (m.find()) {
            words.add(m.group());
        }
        return words;
    }

    public String toLowerCaseSort(String s) {
        char[] chars = s.toLowerCase().toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }
}